﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace GoogleAJAXLibrariesAPI
{

    /// <summary>
    /// Put in the masterfile in the head: <SharePoint:DelegateControl runat="server" ControlId="AdditionalPageHead" AllowMultipleControls="true"/>
    /// </summary>
    public class ScriptLoader : Control
    {
        public string Name { get; set; }
        public string Version { get; set; }
        public bool Uncompressed { get; set; }

        protected override void CreateChildControls()
        {
            Literal initscript = new Literal();
            Controls.Add(initscript);
            initscript.Text = string.Format("<script type=\"text/javascript\">google.load(\"{0}\", \"{1}\",{{uncompressed:{2}}} );</script>", Name, Version, Uncompressed.ToString().ToLower() );

            base.CreateChildControls();

        }
    }
}
